home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 8
/
Amoszine 8 (Disk 2 of 3).adf
/
Powerbobs.lha
/
powerbobsv1.0
/
demos
/
PopCorn.asc
< prev
next >
Wrap
Text File
|
1995-06-30
|
5KB
|
192 lines
' Program : Popcorn
' Author : Paul Overy
'
' POWERBOBS EXTENSION NEEDED.
'
' Once AmosBanK (.abk) is loaded:-
' -- Bank 14 : Holds large logo.
' -- Bank 15 : Stores all gfx for bobs.
'
' This program does not use any floating point calculations!
'
'
Dim MX(64),MY(64),X(64),Y(64),FRM(64)
Dim DISPLAY_X(64),DISPLAY_Y(64),DISPLAY_FRM(64)
Global _BOB_SIZE,_BOBS
'
'-------------------------------------
Load "PowerBobsV1.0:DEMOS/PopCorn.Abk"
'-------------------------------------
'
Proc _SET_UP
Proc _CUT_BOBS
'
Break Off
NULL=Execall(-132) : Rem -- Turn off multitasking
'
'-- Pre-store some of the starting address to arrays
'
_FRM=Varptr(FRM(0))
_Y=Varptr(Y(0))
_X=Varptr(X(0))
_MY=Varptr(MY(0))
_MX=Varptr(MX(0))
_DX=Varptr(DISPLAY_X(0))
_DY=Varptr(DISPLAY_Y(0))
_DFRM=Varptr(DISPLAY_FRM(0))
_CX=Varptr(X(_BOBS))
_CY=Varptr(Y(_BOBS))
_CFRM=Varptr(FRM(_BOBS))
'
Dec _BOBS : Rem Adjust total, arrays start at 0.
'
'-- Set ball frames, and falling speed.
'
For K=0 To _BOBS
FRM(K)=4
MY(K)=-(320-K*32)
' Set Pbob K+1,0,%1000 : Rem Try using this line for more speed
Next K
'-----------------------------------------------------------------------
'
'-- Main start
'
Repeat
'
Pinc _FRM,0 To _BOBS : Rem -- Update all ball images
Padd _MY,16,0 To _BOBS : Rem -- Change falling speed
Psum _Y,_MY,0 To _BOBS : Rem -- Calculate all new Y
Psum _X,_MX,0 To _BOBS : Rem -- Calculate all new X
'
Copy _X,_CX To _DX
Copy _Y,_CY To _DY
Copy _FRM,_CFRM To _DFRM
'
Plsr _DX,5,0 To _BOBS : Rem scale array /32
Plsr _DY,5,0 To _BOBS : Rem scale array /32
Plsr _DFRM,2,0 To _BOBS : Rem scale array /4
'
'-- Reset all values if ball is outside screen area
'-- Values are scaled up, saves on using floating point values
'
For K=0 To _BOBS
If Y(K)>8192 : Rem Y > 256 scaled up by 32.
X(K)=5120 : Rem 160 scaled up by 32
'-- reset starting point
Y(K)=8472-(_BOB_SIZE*32)
MX(K)=Rnd(320)-160 : MY(K)=-(320+Rnd(192))
FRM(K)=4
End If
Next K
'
Pbob _DX,_DY,_DFRM,1 To _BOBS+1 : Rem -- Re-position all bobs
Pbob Update : Rem -- clear old bobs & draw new ones
'
Screen Swap : Wait Vbl
'
Until Not Btst(6,$BFE001) : Rem -- Test for right mouse
'
NULL=Execall(-138) : Rem -- Turn on multitasking
Break On
'
'-- Main End
'-----------------------------------------------------------------------
'
'
Procedure _CUT_BOBS
'
Unpack 15 To 0 : Rem Get graphics from bank
'
N=1 : Rem Bob image counter
'
If _BOB_SIZE=32
'
'-- Cut out large bobs
'
For Y=0 To 32 Step 32
For X=0 To 288 Step 32
Get Bob N,X,Y To X+32,Y+30 : Inc N
Next X
Next Y
Else
'
'-- Cut out small bobs
'
For X=0 To 256 Step 16
Get Bob N,X,Y+64 To X+16,Y+79 : Inc N
Next X
End If
'
Hide : Curs Off : Pen 15 : Paper 0 : Cls 0 : Centre "Left mouse stops"
'
'-- Set up screen buffering to stop flicker
'
Unpack 14 To 0 : Rem -- Get logo screen
Double Buffer : Rem -- Screen buffering to stop flicker
Autoback 0 : Rem -- Turn off Amos automatic screen buffer system
Bob Update Off : Rem -- (not really needed)
Sprite Update Off : Rem -- (not really needed)
Make Mask : Rem -- Must do this, or no masks will be created.
' -- Unlike Amos bobs, for speed this is not
' -- automatic when the bobs are first drawn.
Reserve Pbobs _BOBS : Rem -- The total amount of bobs being used
Pbob Dbuf True : Rem -- Double buffering to be used on Pbobs
'
'Trim bobs to best fit
If _BOB_SIZE=32
PH=30
Else
PH=15
End If
'
For K=1 To _BOBS
Pbob Height K,PH : Rem set height of each Pbob
Next K
'
End Proc
'
Procedure _SET_UP
'
'-- This procedure is for setting up the demo.
'-- No PowerBob commands can be found here.
'
'-- Well apart from "VALUE=Xscrn Mouse",
'-- which is a cut down Amos for "VALUE=X screen(X mouse)".
'
'-- All these Amos commands are fully documented in the Amos user guide
'
Screen Open 0,640,200,4,Hires : Curs Off : Flash Off : Cls 0
Ink 2,0 : Pen 2 : Paper 0
'
Reserve Zone 4 : Rem -- Define 4 option boxes to be set up later
'
Centre "Please Use The Mouse To Select"
Print At(30,12);Zone$(Border$("SMALL",3),1)+Cright$+" or "+Zone$(Border$("LARGE",3),2)+Cright$+" BALLS"
'
Repeat
MZ=Mouse Zone
Until MZ>0 and Mouse Click
'
_BOB_SIZE=MZ*16
'
Print At(26,15);"Number of balls ";Zone$(Border$("OK",3),3)
'
_BOBS=8
'
Set Zone 4,128-64,118 To 196,128
Hslider 130-64,118 To 194,128,64,_BOBS,1
Text 98-64,126,Str$(_BOBS)+" "
'
Repeat
If Mouse Zone=4 and Mouse Key
LAST=_BOBS
_BOBS=Max(2,Min(128,Xscr Mouse-129+64))/2
If LAST<>_BOBS
Hslider 130-64,118 To 194,128,64,_BOBS,1
Text 98-64,126," " : Text 98-64,126,Str$(_BOBS)
End If
End If
Until Mouse Key and Mouse Zone=3
'
End Proc